package com.jeesite.modules.dataScreen.web;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.jeesite.modules.dataScreen.service.DataScreenService;
import com.jeesite.modules.dataScreen.service.OfficeDataScreenService;
import com.jeesite.modules.dataScreen.utils.CacheUtils;
import com.jeesite.modules.dataScreen.utils.DataScreenUtils;
import com.jeesite.modules.dataScreen.utils.OfficeDataScreenUtils;
import com.jeesite.modules.dataScreen.utils.SysCacheUtils;
import com.jeesite.modules.dataScreen.web.vo.Result;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

@Controller
@Api("处室视窗接口")
@RequestMapping("/officeDataScreen")
@Slf4j
public class OfficeDataScreenApi extends BaseController {

    @Resource
    private OfficeDataScreenService officeDataScreenService;
    @Resource
    private DataScreenService dataScreenService;

    @RequestMapping("/getAllData")
    @ResponseBody
    @ApiOperation("获取所有指标数据")
    public Result<?> getAllData() {
        List<Map<String, String>> dataScreen = OfficeDataScreenUtils.getDataScreenAllList();
        return Result.OK(Boolean.TRUE, "查询成功！", dataScreen);
    }

    /**
     * 根据模块关键字查询指标
     *
     * @param key1 模块名
     * @param key2 子模块名
     * @param key3 子子模块名
     * @return 结果
     */
    @RequestMapping("/getDataByKeys")
    @ResponseBody
    @ApiOperation("根据模块关键字查询指标")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key1", value = "关键字1"),
            @ApiImplicitParam(name = "key2", value = "关键字2"),
            @ApiImplicitParam(name = "key3", value = "关键字3"),
            @ApiImplicitParam(name = "key4", value = "关键字4")
    })
    public Result<?> getDataByKeys(String key1, String key2, String key3, String key4) {
        log.debug("查询参数 => {},{},{},{}", key1, key2, key3, key4);
        List<Map<String, String>> dataScreen = OfficeDataScreenUtils.getOfficeDataScreenList(key1, key2, key3, key4);
        return Result.OK(Boolean.TRUE, "查询成功！", dataScreen);
    }


    /**
     * 【建管处】获取“开工项目”、“开工里程”柱形图的接口
     */
    @RequestMapping("/jg/getStartProjectMileageData")
    @ResponseBody
    @ApiOperation("获取“开工项目”、“开工里程”柱形图")
    public Result<?> getStartProjectMileageData() {
        Map<String, Map<String, Map<String, List<String>>>> data = startWorkingAndHaveTransportService("开工");
        return Result.OK(Boolean.TRUE, "查询成功", data);
    }

    /**
     * 【建管处】获取“通车项目”、“通车里程”柱形图的接口
     */
    @RequestMapping("/jg/getOpenProjectMileageData")
    @ResponseBody
    @ApiOperation("获取“通车项目”、“通车里程”柱形图")
    public Result<?> getOpenProjectMileageData() {
        Map<String, Map<String, Map<String, List<String>>>> data = startWorkingAndHaveTransportService("通车");
        return Result.OK(Boolean.TRUE, "查询成功", data);
    }

    /**
     * 【建管处】获取“建设里程(行政/技术)”柱形图的接口
     */
    @RequestMapping("/jg/getConstructionMileageData")
    @ResponseBody
    @ApiOperation("获取“建设里程(行政/技术)”柱形图")
    public Result<?> getConstructionMileageData() {
        Map<String, Map<String, Map<String, List<String>>>> data = SysCacheUtils.get(OfficeDataScreenUtils.CACHE_CONSTRUCTION_MILEAGE_DATA);
        if (data == null) {
            data = new HashMap<>();
            List<Map<String, String>> OfficeWindowDataByCacheKeyList = officeDataScreenService.getConstructionMileageData();
            List<String> xzXAxis = new ArrayList<>();
            List<String> xzData = new ArrayList<>();
            List<String> jsXAxis = new ArrayList<>();
            List<String> jsData = new ArrayList<>();

            for (Map<String, String> map : OfficeWindowDataByCacheKeyList) {
                if (map.get("key3").equals("行政等级")) {
                    if (xzXAxis.isEmpty()) {
                        xzXAxis.add(map.get("name"));
                    } else {
                        boolean isIn = false;
                        for (String str : xzXAxis) {
                            isIn = str.equals(map.get("name"));
                            if (isIn) {
                                break;
                            }
                        }
                        if (!isIn) {
                            xzXAxis.add(map.get("name"));
                        }
                    }

                    int index = xzXAxis.indexOf(map.get("name"));
                    if (index > xzData.size()) {
                        xzData.add(map.get("data"));
                        int distance = index - xzData.size();  // 计算要移动的距离
                        Collections.rotate(xzData, distance);  // 将元素移动到指定的下标位置
                    } else {
                        xzData.add(index, map.get("data"));
                    }
                } else if (map.get("key3").equals("技术等级")) {
                    if (jsXAxis.isEmpty()) {
                        jsXAxis.add(map.get("name"));
                    } else {
                        boolean isIn = false;
                        for (String str : jsXAxis) {
                            isIn = str.equals(map.get("name"));
                            if (isIn) {
                                break;
                            }
                        }
                        if (!isIn) {
                            jsXAxis.add(map.get("name"));
                        }
                    }
                    int index = jsXAxis.indexOf(map.get("name"));
                    if (index > jsData.size()) {
                        jsData.add(map.get("data"));
                        int distance = index - jsData.size();  // 计算要移动的距离
                        Collections.rotate(jsData, distance);  // 将元素移动到指定的下标位置
                    } else {
                        jsData.add(index, map.get("data"));
                    }
                }
            }
            data.put("data", new HashMap<>());
            data.get("data").put("xzChart", new HashMap<>());
            data.get("data").get("xzChart").put("xAxis", xzXAxis);
            data.get("data").get("xzChart").put("data", xzData);
            data.get("data").put("jsChart", new HashMap<>());
            data.get("data").get("jsChart").put("xAxis", jsXAxis);
            data.get("data").get("jsChart").put("data", jsData);
            SysCacheUtils.put(OfficeDataScreenUtils.CACHE_CONSTRUCTION_MILEAGE_DATA, data);
        }

        return Result.OK(Boolean.TRUE, "查询成功", data);
    }

    /**
     * 管养处-首页-获取“当日入口流量”实时数据
     * 管养处-首页-获取“当日出口流量”实时数据
     * 管养处-首页-获取“当日在网车辆”实时数据
     * 三合一接口
     *
     * @return 结果
     */
    @RequestMapping("/gy/getHighwayEntranceFlowData")
    @ResponseBody
    @ApiOperation("获取“当日流量”实时数据")
    public Result<?> getFlowData() {
        //将字符串常量存入List中
        List<String> cacheKeys = Arrays.asList(OfficeDataScreenUtils.CACHE_HIGHWAY_ENTRANCE_FLOW_DATA, OfficeDataScreenUtils.CACHE_HIGHWAY_EXIT_FLOW_DATA, OfficeDataScreenUtils.CACHE_ROAD_NETWORK_DATA);
        List<String> names = Arrays.asList("当日入口流量", "当日出口流量", "当日在网车辆");

        List<Map<String, Object>> data = new ArrayList<>();
        for (int i = 0; i < cacheKeys.size(); i++) {
            //从缓存中获取动态数据
            long resValue = getDynamicDataByCache(cacheKeys.get(i), String.valueOf(i + 1));
            Map<String, Object> map = MapUtil.newHashMap();

            map.put("data", resValue);
            map.put("name", names.get(i));
            data.add(map);
        }

        return Result.OK(Boolean.TRUE, "查询成功！", data);
    }

    /**
     * 在缓存中取得各个动态数据指标的最新数据
     *
     * @param cacheKey 缓存的键名
     * @return 最新数据
     */
    private Long getDynamicDataByCache(String cacheKey, String index) {
        Map<String, Object> data = MapUtil.newHashMap();
        Map<String, Object> cacheMap = CacheUtils.get(DataScreenUtils.CACHE_NAME_SCREEN_DYNAMIC, cacheKey);
        // 最新的值、步长
        long lastData, nextIndex, difference;
        // 缓存存入时间、系统当前时间
        Date lastDate, nowDate = DateUtil.date();
        // 时间的差值
        long td = 0L;
        if (cacheMap == null || cacheMap.isEmpty()) {
            if ("1".equals(index)) {
                // 管养处-首页-获取“当日入口流量”实时数据
                data = officeDataScreenService.getHighwayEntranceFlowData();
            } else if ("2".equals(index)) {
                // 管养处-首页-获取“当日出口流量”实时数据
                data = officeDataScreenService.getHighwayExitFlowData();
            } else if ("3".equals(index)) {
                // 管养处-首页-获取“当日在网车辆”实时数据
                data = officeDataScreenService.getRoadNetworkData();
            }
            // 最新的值
            lastData = Long.parseLong(data.get("lastData").toString());
            // 差值
            difference = Long.parseLong(data.get("difference").toString());
            // 缓存存入时间
            data.put("lastDate", nowDate);
            // 步长
            nextIndex = (int) Math.floor((double) difference / 60);
            CacheUtils.put(DataScreenUtils.CACHE_NAME_SCREEN_DYNAMIC, cacheKey, data);
        } else {
            // 最新的值
            lastData = Long.parseLong(cacheMap.get("lastData").toString());
            // 缓存存入时间
            lastDate = (Date) cacheMap.get("lastDate");
            // 时间的差值
            td = (nowDate.getTime() - lastDate.getTime()) / 1000;
            // 数据的差值
            difference = Long.parseLong(cacheMap.get("difference").toString());
            // 步长
            nextIndex = (int) Math.floor((double) difference / 60);
        }
        return (lastData + nextIndex * (td + RandomUtil.randomInt(-2, 2)));
    }

    /**
     * 【建管处】获取“运营里程(行政/技术)”柱形图
     *
     * @return 结果
     */
    @RequestMapping("/jg/getOperatingMileageData")
    @ResponseBody
    @ApiOperation("获取“运营里程(行政/技术)”柱形图")
    public Result<?> getOperatingMileageData() {
        Map<String, Object> dataMap = CacheUtils.get(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_OPERATING_MILEAGE_DATA");
        if (dataMap == null || dataMap.isEmpty()) {
            //获取运营里程(行政/技术)的数据列表
            List<Map<String, Object>> listData = officeDataScreenService.getOperatingMileageData();
            //筛选数据列表，得到行政等级图表数据与技术等级图表所需数据
            dataMap = MapUtil.newHashMap();
            dataMap.put("xzChart", processData(listData, "行政等级"));
            dataMap.put("jsChart", processData(listData, "技术等级"));
            CacheUtils.put(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_OPERATING_MILEAGE_DATA", dataMap);
        }
        Map<String, Object> data = MapUtil.newHashMap();
        data.put("data", dataMap);
        return Result.OK(Boolean.TRUE, "查询成功！", data);
    }

    /**
     * @param listData 运营里程(行政/技术)的数据列表
     * @param level    行政或技术等级
     * @return 筛选后的结果
     */
    private Map<String, Object> processData(List<Map<String, Object>> listData, String level) {
        List<Object> data = listData.stream().filter(item -> item.containsValue(level)).map(item -> item.get("data")).collect(Collectors.toList());
        List<Object> xAxis = listData.stream().filter(item -> item.containsValue(level)).map(item -> item.get("name")).collect(Collectors.toList());
        Map<String, Object> chartData = MapUtil.newHashMap();
        chartData.put("xAxis", xAxis);
        chartData.put("data", data);
        return chartData;
    }

    /**
     * 获取“开工项目”、“开工里程”柱形图和获取“通车项目”、“通车里程”柱形图数据的共同方法
     */
    private Map<String, Map<String, Map<String, List<String>>>> startWorkingAndHaveTransportService(String judgment) {
        Map<String, Map<String, Map<String, List<String>>>> data = null;
        if (judgment.equals("开工")) {
            data = SysCacheUtils.get(OfficeDataScreenUtils.CACHE_START_PROJECT_MILEAGE_DATA);
        } else if (judgment.equals("通车")) {
            data = SysCacheUtils.get(OfficeDataScreenUtils.CACHE_OPEN_PROJECT_MILEAGE_DATA);
        }
        if (data == null) {
            data = new HashMap<>();
            List<Map<String, String>> OfficeWindowDataByCacheKeyList = new ArrayList<>();
            if (judgment.equals("开工")) {
                OfficeWindowDataByCacheKeyList = officeDataScreenService.getStartProjectMileageData();
            } else if (judgment.equals("通车")) {
                OfficeWindowDataByCacheKeyList = officeDataScreenService.getOpenProjectMileageData();
            }
            List<String> projectXAxis = new ArrayList<>();
            List<String> projectJhData = new ArrayList<>();
            List<String> projectLjData = new ArrayList<>();
            List<String> mileageXAxis = new ArrayList<>();
            List<String> mileageJhData = new ArrayList<>();
            List<String> mileageLjData = new ArrayList<>();
            for (Map<String, String> map : OfficeWindowDataByCacheKeyList) {
                if (map.get("key2").equals("开工项目") || map.get("key2").equals("通车项目")) {
                    if (projectXAxis.isEmpty()) {
                        projectXAxis.add(map.get("key3"));
                    } else {
                        boolean isIn = false;
                        for (String str : projectXAxis) {
                            isIn = str.equals(map.get("key3"));
                            if (isIn) {
                                break;
                            }
                        }
                        if (!isIn) {
                            projectXAxis.add(map.get("key3"));
                        }
                    }
                    int projectIndex = projectXAxis.indexOf(map.get("key3"));
                    if (map.get("name").equals("计划开工项目") || map.get("name").equals("计划通车项目")) {
                        if (projectIndex > projectJhData.size()) {
                            projectJhData.add(map.get("data"));
                            int distance = projectIndex - projectJhData.size();  // 计算要移动的距离
                            Collections.rotate(projectJhData, distance);  // 将元素移动到指定的下标位置
                        } else {
                            projectJhData.add(projectIndex, map.get("data"));
                        }
                    }
                    if (map.get("name").equals("累计开工项目") || map.get("name").equals("累计通车项目")) {
                        if (projectIndex > projectLjData.size()) {
                            projectLjData.add(map.get("data"));
                            int distance = projectIndex - projectLjData.size();  // 计算要移动的距离
                            Collections.rotate(projectLjData, distance);  // 将元素移动到指定的下标位置
                        } else {
                            projectLjData.add(projectIndex, map.get("data"));
                        }
                    }
                } else if (map.get("key2").equals("开工里程") || map.get("key2").equals("通车里程")) {
                    if (mileageXAxis.isEmpty()) {
                        mileageXAxis.add(map.get("key3"));
                    } else {
                        boolean isIn = false;
                        for (String str : mileageXAxis) {
                            isIn = str.equals(map.get("key3"));
                            if (isIn)
                                break;
                        }
                        if (!isIn) {
                            mileageXAxis.add(map.get("key3"));
                        }
                    }

                    int mileageIndex = mileageXAxis.indexOf(map.get("key3"));

                    if (map.get("name").equals("计划开工里程") || map.get("name").equals("计划通车里程")) {
                        if (mileageIndex > mileageJhData.size()) {
                            mileageJhData.add(map.get("data"));
                            int distance = mileageIndex - mileageJhData.size();  // 计算要移动的距离
                            Collections.rotate(mileageJhData, distance);  // 将元素移动到指定的下标位置
                        } else {
                            mileageJhData.add(mileageIndex, map.get("data"));
                        }
                    }

                    if (map.get("name").equals("累计开工里程") || map.get("name").equals("累计通车里程")) {
                        if (mileageIndex > mileageLjData.size()) {
                            mileageLjData.add(map.get("data"));
                            int distance = mileageIndex - mileageLjData.size();  // 计算要移动的距离
                            Collections.rotate(mileageLjData, distance);  // 将元素移动到指定的下标位置
                        } else {
                            mileageLjData.add(mileageIndex, map.get("data"));
                        }
                    }
                }
            }

            data.put("data", new HashMap<>());
            data.get("data").put("projectChart", new HashMap<>());
            data.get("data").get("projectChart").put("xAxis", projectXAxis);
            data.get("data").get("projectChart").put("jhData", projectJhData);
            data.get("data").get("projectChart").put("ljData", projectLjData);
            data.get("data").put("mileageChart", new HashMap<>());
            data.get("data").get("mileageChart").put("xAxis", mileageXAxis);
            data.get("data").get("mileageChart").put("jhData", mileageJhData);
            data.get("data").get("mileageChart").put("ljData", mileageLjData);
            SysCacheUtils.put(OfficeDataScreenUtils.CACHE_START_PROJECT_MILEAGE_DATA, data);
        }
        return data;
    }

    @RequestMapping("/jg/getInvestmentScaleData")
    @ResponseBody
    @ApiModelProperty("获取 投资规模 环形图数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年份")
    })
    public Result<?> getInvestmentScaleData(@RequestParam(required = false) String year) {
        log.info("投资规模 环形图传入参数 =====>" + year);
        // 1.判断是否传入year
        if (year == null) {
            year = String.valueOf(DateUtil.thisYear());
        }
        //2.获取原始数据
        Map<String, List<Map<String, Object>>> investmentScaleData = OfficeDataScreenUtils.getInvestmentScaleData(year);
        return Result.OK(Boolean.TRUE, "查询成功！", investmentScaleData);
    }

    @RequestMapping("/gy/getEmergenciesData")
    @ResponseBody
    @ApiModelProperty("获取 突发事件 环形图数据")
    public Result<?> getEmergenciesData() {
        log.info("开始获取 突发事件 环形图数据");
        //1.获取原始数据
        List<Map<String, Object>> emergenciesData = OfficeDataScreenUtils.getEmergenciesData();
        int totlal = 0;
        for (Map<String, Object> emergenciesDatum : emergenciesData) {
            totlal += Integer.parseInt(emergenciesDatum.get("value").toString());
        }
        Map<String, Object> map = MapUtil.newHashMap();
        map.put("data", emergenciesData);
        map.put("total", totlal);
        return Result.OK(Boolean.TRUE, "查询成功！", map);
    }

    @RequestMapping("/gy/getTrafficIndexData")
    @ResponseBody
    @ApiModelProperty("获取 交通指数 数据")
    public Result<?> getTrafficIndexData() {
        log.info("开始获取 交通指数 数据");
        Map<String, Object> trafficIndexData = OfficeDataScreenUtils.getTrafficIndexData();
        Map<String, Object> data = MapUtil.newHashMap();
        data.put("data", trafficIndexData);
        return Result.OK(Boolean.TRUE, "查询成功", data);
    }

    @RequestMapping("/gy/getRegulatoryData")
    @ResponseBody
    @ApiModelProperty("获取 管制情况 指标数据")
    public Result<?> getRegulatoryData() {
        log.info("开始获取 管制情况 指标数据");
        List<Map<String, Object>> regulatoryData = OfficeDataScreenUtils.getRegulatoryData();
        return Result.OK(Boolean.TRUE, "查询成功！", regulatoryData);
    }

    @RequestMapping("clearCache")
    @ResponseBody
    @ApiOperation("清除指标缓存")
    public Result<?> clearCache() {
        OfficeDataScreenUtils.clearCache();
        return Result.OK(Boolean.TRUE, "清除缓存成功！", null);
    }

    /**
     * 科技处视窗 应用规模-运输(指标)
     */
    @RequestMapping("/kj/getTransportationScale")
    @ResponseBody
    @ApiModelProperty("获取 应用规模-运输 指标数据")
    public Result<?> getTransportationScale() {
        List<Map<String, Object>> list = CacheUtils.get(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_KJ_TRANSPORT_ATION_SCALE_DATA");
        if (list == null || list.isEmpty()){
            list = new ArrayList<>();
            Map<String, Object> map1 = officeDataScreenService.getTransportationScale("当月运单数", "wnomi", "单");
            Map<String, Object> map2 = officeDataScreenService.getTransportationScale("累计运单数", "round(wnosum/10000,2)", "万单");
            Map<String, Object> map3 = officeDataScreenService.getTransportationScale("累计货运量", "round(ftosum/10000,2)", "万吨");
            list.add(map1);
            list.add(map2);
            list.add(map3);
            CacheUtils.put(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_TRANSPORT_ATION_SCALE_DATA", list);
        }
        return Result.OK(Boolean.TRUE, "查询成功！", list);
    }

    /**
     * 管养处-收费-经营单位(柱形图)
     */
    @RequestMapping("/gy/getRevenueSituation")
    @ResponseBody
    @ApiModelProperty("获取 管养处-收费-经营单位(柱形图)")
    public Result<?> getRevenueSituation() {
        Map<String, Object> data = CacheUtils.get(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_GY_REVENUE_SITUATION_DATA");
        if (data == null || data.isEmpty()) {

            List<Map<String, Object>> list = officeDataScreenService.getFeeBasedBusData();
            // 最近几年的营收情况
            List<Object> srList = new ArrayList<>();
            List<Object> cbList = new ArrayList<>();
            List<Object> nfList = new ArrayList<>();
            for (Map<String, Object> map : list) {
                Object sr = map.get("sr");
                Object cb = map.get("cb");
                Object nf = map.get("nf");
                if (sr != null) {
                    srList.add(sr);
                }
                if (cb != null) {
                    cbList.add(cb);
                }
                if (nf != null) {
                    nfList.add(nf);
                }
            }
            data = MapUtil.newHashMap();
            data.put("sr", srList);
            data.put("cb", cbList);
            data.put("nf", nfList);
            data.put("unit", "万元");
            CacheUtils.put(DataScreenUtils.CACHE_NAME_SCREEN_LIST, "CACHE_KEY_GY_REVENUE_SITUATION_DATA", data);
        }
        return Result.OK(Boolean.TRUE, "查询成功！", data);
    }

    /**
     * 规划处-实时路况-客运监测-出租车、网约车、联网售票(指标)
     *
     * @param type (1=出租车、2=网约车、3=联网售票、4=轨道、5=公交) 默认等于1
     */
    @RequestMapping("/gh/getTransportPassenger")
    @ResponseBody
    @ApiModelProperty("划处-实时路况-客运监测-出租车、网约车、联网售票(指标)")
    public Result<?> getTransportPassenger(String type) {
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> m1 = null, m2 = null, m3 = null;
        if (StrUtil.isEmpty(type)) {
            type = "1";
        }
        switch (type) {
            case "1":
                // 出租车
                // 巡游出租车客流量
                m1 = MapUtil.newHashMap();
                m1.put("name", "巡游出租车客流量");
                m1.put("data", dataScreenService.getTransportPassengerData("xycdrkll"));
                m1.put("unit", "人次");
                // 巡游出租车上线运力
                m2 = MapUtil.newHashMap();
                m2.put("name", "巡游出租车上线运力");
                m2.put("data", dataScreenService.getTransportPassengerData("xycsxyl"));
                m2.put("unit", "辆");
                // 巡游出租车平均载客次数
                m3 = MapUtil.newHashMap();
                m3.put("name", "巡游出租车平均载客次数");
                m3.put("data", dataScreenService.getTransportPassengerData("xycpjzkcs"));
                m3.put("unit", "人次");
                break;
            case "2":
                // 网约车
                // 网约车客流量
                m1 = MapUtil.newHashMap();
                m1.put("name", "网约车客流量");
                m1.put("data", dataScreenService.getTransportPassengerData("wycdrkll"));
                m1.put("unit", "人次");
                // 网约车上线运力
                m2 = MapUtil.newHashMap();
                m2.put("name", "网约车上线运力");
                m2.put("data", dataScreenService.getTransportPassengerData("wycsxyl"));
                m2.put("unit", "辆");
                // 网约车平均载客次数
                m3 = MapUtil.newHashMap();
                m3.put("name", "网约车平均载客次数");
                m3.put("data", dataScreenService.getTransportPassengerData("wycpjdds"));
                m3.put("unit", "人次");
                break;
            case "3":
                // 联网售票
                // 联网售票运力
                m1 = MapUtil.newHashMap();
                m1.put("name", "联网售票运力");
                m1.put("data", dataScreenService.getRoadWayPassengerData("yunli"));
                m1.put("unit", "条");
                // 联网售票班次
                m2 = MapUtil.newHashMap();
                m2.put("name", "联网售票班次");
                m2.put("data", dataScreenService.getRoadWayPassengerData("liner_count"));
                m2.put("unit", "次");
                // 联网售票总客流
                m3 = MapUtil.newHashMap();
                m3.put("name", "联网售票总客流");
                m3.put("data", dataScreenService.getRoadWayPassengerData("check_num"));
                m3.put("unit", "人次");
                break;
            case "4":
                // 轨道
                // 轨道断面客流
                m1 = MapUtil.newHashMap();
                m1.put("name", "轨道断面客流");
                m1.put("data", 0);
                m1.put("unit", "人次");
                // 轨道上线运力
                m2 = MapUtil.newHashMap();
                m2.put("name", "轨道上线运力");
                m2.put("data", dataScreenService.getRailTransitPassengerData("online_transport"));
                m2.put("unit", "万人次");
                // 轨道列次
                m3 = MapUtil.newHashMap();
                m3.put("name", "轨道列次");
                m3.put("data", dataScreenService.getRailTransitPassengerData("negative_num"));
                m3.put("unit", "列");
                // 轨道全天客流
                Map<String, Object> m4 = MapUtil.newHashMap();
                m4.put("name", "轨道全天客流");
                m4.put("data", dataScreenService.getRailTransitPassengerData("flow"));
                m4.put("unit", "万人次");
                // 轨道运营里程
                Map<String, Object> m5 = MapUtil.newHashMap();
                m5.put("name", "轨道运营里程");
                m5.put("data", dataScreenService.getRailTransitPassengerData("operate_mileage"));
                m5.put("unit", "万公里");
                // 轨道营运车列
                Map<String, Object> m6 = MapUtil.newHashMap();
                m6.put("name", "轨道营运车列");
                m6.put("data", dataScreenService.getRailTransitPassengerData("operate_train_num"));
                m6.put("unit", "列");
                list.add(m4);
                list.add(m5);
                list.add(m6);
                break;
            case "5":
                // 公交
                // 公交上线运力
                m1 = MapUtil.newHashMap();
                m1.put("name", "公交上线运力");
                m1.put("data", dataScreenService.getPublicTransitPassengerData("online_capacity"));
                m1.put("unit", "辆");
                // 公交总客流
                m2 = MapUtil.newHashMap();
                m2.put("name", "公交总客流");
                m2.put("data", dataScreenService.getPublicTransitPassengerData("flow"));
                m2.put("unit", "人次");
                // 公交班次
                m3 = MapUtil.newHashMap();
                m3.put("name", "公交班次");
                m3.put("data", dataScreenService.getPublicTransitPassengerData("shift"));
                m3.put("unit", "人次");
                break;
        }
        list.add(m1);
        list.add(m2);
        list.add(m3);
        return Result.OK(Boolean.TRUE, "查询成功！", list);
    }

    /**
     * 管养处-收费-收费单位公路排名(列表)
     *
     * @param sortOrder 排序方式(1=顺序,2=倒序)
     */
    @RequestMapping("/gy/getHighWayTollRankTopData")
    @ResponseBody
    @ApiModelProperty("获取 管养处-收费-收费公路排名(列表)")
    public Result<?> getHighWayTollRankTopData(String sortOrder) {
        String order;
        if (StrUtil.isEmpty(sortOrder)) {
            sortOrder = "1";
        }
        if (sortOrder.equals("1")) {
            order = "desc";
        } else {
            order = "asc";
        }
        List<Map<String, String>> data = officeDataScreenService.getHighWayTollRankTopData(order);
        return Result.OK(Boolean.TRUE, "查询成功！", data);
    }

    /**
     * 港航处-水运现状(指标)
     *
     */
    @RequestMapping("/gangh/getWaterTransportData")
    @ResponseBody
    @ApiModelProperty("获取 港航处-水运现状(指标)")
    public Result<?> getWaterTransportData() {
        // 内河航道里程、港口货物吞吐能力、集装箱吞吐能力
        List<Map<String, Object>> maps = dataScreenService.getTargetDataByIds("270", "272");
        maps.addAll(dataScreenService.getTargetDataById("226"));

        // 货物吞吐量（万吨）
        Map<String, Object> m1 = MapUtil.newHashMap();
        m1.put("name", "货物吞吐量");
        m1.put("value", officeDataScreenService.getWaterTransportData("hwttl"));
        m1.put("unit", "万吨");
        maps.add(m1);
        // 集装箱吞吐量（万TEU）
        Map<String, Object> m2 = MapUtil.newHashMap();
        m2.put("name", "集装箱吞吐量");
        m2.put("value", officeDataScreenService.getWaterTransportData("jzxtll"));
        m2.put("unit", "万TEU");
        maps.add(m2);
        // 货运量（万吨）
        Map<String, Object> m3 = MapUtil.newHashMap();
        m3.put("name", "货运量");
        m3.put("value", officeDataScreenService.getWaterTransportData("hyl"));
        m3.put("unit", "万吨");
        maps.add(m3);

        return Result.OK(Boolean.TRUE, "查询成功！", maps);
    }

}